<template>
    <div class="add">
        <!-- <h1>当前最新的count值为：{{this.$store.state.count}}</h1> -->
        <h1>{{showNum}}</h1>
        <button @click="add">+1</button>
        <button @click="add5">+5</button>
        <button @click="addAsync">1 秒之后 +1</button>
    </div>
</template>
<script>
import { mapGetters } from "vuex"
export default {
    data(){
        return{
        }
    },
    methods:{
        add(){
            this.$store.commit("add",1)
        },
        add5(){
            this.$store.commit("add",5)
        },
        addAsync(){
            this.$store.dispatch("addAsync",1)
        }
    },
    computed:{
        ...mapGetters(["showNum"])
    }
}
</script>